home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha Extra 2004 January / CyberMycha Extra 1-2004 (Poland) (Disc 2).bin / Pippi / common.cst / 00034_monkeyScript.ls < prev    next >
Encoding:
Text File  |  2001-09-04  |  16.5 KB  |  479 lines

  1. property MEMBERSX, POSITIONS
  2. property meSprite, buttonSprite
  3. property activityList, activity, formerActivity, positionH, positionV, positionHButtons, monkeyRunning --actualSettings
  4. property playList --list of movements to do
  5. property Pname, Ploc --casual props
  6. property ULstopList, URstopList, upButtonHListL, upButtonHListR, DLstopList, DRstopList, downButtonHList, buttonHvalue, stopNum, initPlay, buttonV --buttonStopsInFlashMovies
  7. property transMember, transLoc, transFrame
  8. property myColor
  9. global sessionObject
  10.  
  11. property percentFrame, turnMonkey
  12.  
  13. --------------------------------------------------------------------------------------------------------------------------------
  14. --recieve calls from buttons and timeOut, make a profile 
  15. --------------------------------------------------------------------------------------------------------------------------------
  16. on testCall me
  17.   monkeyRunning = 1
  18.   playList = [[#movesHorizontal, #R], [#corners, #D], [#movesVertical, #D], [#corners, #R], [#movesHorizontal, #R], [#corners, #U], [#movesVertical, #U], [#corners, #S], [#rests, #S]]
  19.   meSprite.activate()
  20. end
  21.  
  22. on callFromUpButton me, whichButton, whichSprite
  23.   if activity = #b then
  24.     exit
  25.   else
  26. --    meSprite.holdMonkey()
  27.     monkeyRunning = 1
  28.     buttonV = #U
  29.     buttonSprite = whichSprite
  30.     
  31.     if (activity = #R or activity = #A) = 0 then --om han inte ├ñr p├Ñ v├ñg horisontellt s├Ñ ska han f├Ñ en av de tv├Ñ s├ñtten
  32.       if random(2) = 1 then
  33.         multiply = 2 --v├ñrde f├╢r att hitta r├ñtt nuffra i swf f├╢r att stanna vid r├ñtt knapp, armg├Ñng ├ñr ca dubbelt s├Ñ m├Ñnga frames som springa
  34.         buttonActivity = #A
  35.       else
  36.         multiply = 1
  37.         buttonActivity = #R
  38.       end if
  39.     else
  40.       buttonActivity = activity
  41.       if activity = #A then
  42.         multiply = 2
  43.       else
  44.         multiply = 1
  45.       end if
  46.     end if
  47.     if activity = #C then
  48.       meSprite.frameEnd()
  49.       playList = [[#rests, #S], [#movesHorizontal, buttonActivity], [#buttons, #B]]
  50.     else if activity = #S then --om han vilar sig den late faan!
  51.       playList = [[#movesHorizontal, buttonActivity], [#buttons, #B]] --denna lista ska utf├╢ras f├╢re dir-fil-bytet
  52.     else if activity = #D then
  53.       interruptMonkeyUpDown me
  54.       if the result = 1 then
  55.         playList = [[#movesHorizontal, buttonActivity], [#buttons, #B]]
  56.         positionV = #U
  57.       else
  58.         playList = [[#movesVertical, #U], [#corners, #R], [#movesHorizontal, buttonActivity], [#buttons, #B]]
  59.       end if
  60.     else if activity = #U then
  61.       playList = [[#corners, #R], [#movesHorizontal, buttonActivity], [#buttons, #B]]
  62.       ---------------------------------
  63.     else if activity = #R or activity = #A then
  64.       if positionV = #U then --d├ñr uppe
  65.         interruptMonkeyHorisontal me, whichButton, multiply
  66.         if the result = 2 then
  67.           playList = [[#movesHorizontal, buttonActivity], [#buttons, #B]]
  68.         else if the result = 1 then
  69.           meSprite.activate(stopNum)
  70.           exit
  71.         else
  72.           playList = [[#movesHorizontal, buttonActivity], [#buttons, #B]]
  73.         end if
  74.         ----------------------------------      
  75.       else --d├ñr nere
  76.         playList = [[#corners, #U], [#movesVertical, #U], [#corners, #R], [#movesHorizontal, buttonActivity], [#buttons, #B]]
  77.       end if
  78.     end if
  79.     initPlay = [[#movesHorizontal, buttonActivity], [#rests, #S]] --denna lista ska utf├╢ras efter dir-fil-bytet n├ñr apan har tryckt och ska springa hem igen
  80.     if positionH = #L then
  81.       stopNum = (ULstopList[whichButton]) * multiply
  82.       buttonHvalue = upButtonHListL[whichButton]
  83.     else
  84.       stopNum = (URstopList[whichButton]) * multiply
  85.       buttonHvalue = upButtonHListR[whichButton]
  86.     end if
  87.     if activity = #C then
  88.       meSprite.frameEnd()
  89.     end if
  90.     if turnMonkey <> 0 then ---nytt
  91.       reloadMe me ---nytt
  92.     end if ---nytt
  93.     meSprite.activate(stopNum)
  94.   end if
  95. end
  96.  
  97. on callFromDownButton me, whichButton, whichSprite
  98.   if activity = #b then
  99.     exit
  100.   else
  101. --    meSprite.holdMonkey()
  102.     monkeyRunning = 1
  103.     if whichButton < 3 then
  104.       positionHButtons = #L
  105.     else
  106.       positionHButtons = #R
  107.     end if
  108.     buttonV = #D
  109.     buttonSprite = whichSprite
  110.     if activity = #C then
  111.       meSprite.frameEnd()
  112.       playList = [[#rests, #S], [#corners, #D], [#movesVertical, #D], [#corners, #R], [#movesHorizontal, #R], [#buttons, #B]]
  113.     else if activity = #S then --om han vilar sig den late faan!
  114.       playList = [[#corners, #D], [#movesVertical, #D], [#corners, #R], [#movesHorizontal, #R], [#buttons, #B]] --dessa listor ska utf├╢ras f├╢re dir-fil-bytet
  115.     else if activity = #D then
  116.       playList = [[#corners, #R], [#movesHorizontal, #R], [#buttons, #B]]
  117.     else if activity = #U then
  118.       interruptMonkeyUpDown me
  119.       if the result = 1 then
  120.         playList = [[#movesHorizontal, #R], [#buttons, #B]]
  121.         positionV = #D
  122.       else
  123.         playList = [[#movesVertical, #D], [#corners, #R], [#movesHorizontal, #R], [#buttons, #B]]
  124.       end if
  125.     else if activity = #R or activity = #A then
  126.       if positionV = #D then --d├ñr nere
  127.         interruptMonkeyHorisontal me, whichButton
  128.         if the result = 2 then
  129.           playList = [[#movesHorizontal, #R], [#buttons, #B]]
  130.         else if the result = 1 then
  131.           meSprite.activate(stopNum)
  132.           exit
  133.         else
  134.           playList = [[#movesHorizontal, #R], [#buttons, #B]]
  135.         end if
  136.       else --d├ñr uppe
  137.         playList = [[#corners, #D], [#movesVertical, #D], [#corners, #R], [#movesHorizontal, #R], [#buttons, #B]]
  138.       end if
  139.     end if
  140.     initPlay = [[#movesHorizontal, #R], [#corners, #U], [#movesVertical, #U], [#corners, #S], [#rests, #S]] --denna lista ska utf├╢ras efter dir-fil-bytet
  141.     if positionH = #L then
  142.       stopNum = DLstopList[whichButton]
  143.     else
  144.       stopNum = DRstopList[whichButton]
  145.     end if
  146.     buttonHvalue = downButtonHList[whichButton]
  147.     if turnMonkey <> 0 then ---nytt
  148.       reloadMe me ---nytt
  149.     end if ---nytt
  150.     meSprite.activate(stopNum)
  151.   end if
  152. end
  153.  
  154.  
  155. on callFromStage me
  156.   if activity = #b then
  157.     exit
  158.   else
  159. --    meSprite.holdMonkey()
  160.     if activity <> #S then --om han inte vilar sig, om han ├ñr p├Ñ v├ñg, s├Ñ m├Ñste man avbryta aktiviteten och mata in en ny playlist
  161.       meSprite.ButNum = 0 --se till s├Ñ han inte stannar vid en knapp
  162.       if activity = #R or activity = #A then --om han ├ñr i f├ñrd med att springa eller armkroka sig fram horisontellt...
  163.         if positionV = #U then --d├ñr uppe
  164.           playList = [[#rests, #S]]
  165.         else --d├ñr nere
  166.           playList = [[#corners, #U], [#movesVertical, #U], [#corners, #S], [#rests, #S]]
  167.         end if
  168.       else if activity = #D then --om han ├ñr p├Ñ v├ñg ner
  169.         playList = [[#movesVertical, #U], [#corners, #S], [#rests, #S]]
  170.       else if activity = #U then --om han ├ñr p├Ñ v├ñg upp
  171.         playList = [[#corners, #S], [#rests, #S]]
  172.       end if
  173.     end if
  174.   end if
  175. end
  176.  
  177. on restMe me
  178.   playList = [[#rests, #S]]
  179.   meSprite.activate(0)
  180.   positionV = #U
  181. end
  182.  
  183. on chocoMe me
  184.   if activity = #S then
  185.     if positionH = #R then
  186.       playList = [[#movesHorizontal, #R], [#choco, #C], [#rests, #S]]
  187.     else
  188.       playList = [[#choco, #C], [#rests, #S]]
  189.     end if
  190.   else
  191.     if positionV = #D then
  192.       if positionH = #R then
  193.         playList = [[#corners, #U], [#movesVertical, #U], [#corners, #R], [#movesHorizontal, #R], [#choco, #C], [#rests, #S]]
  194.       else
  195.         playList = [[#corners, #U], [#movesVertical, #U], [#corners, #S], [#rests, #S], [#choco, #C], [#rests, #S]]
  196.       end if
  197.     else
  198.       if positionH = #R then
  199.         playList = [[#movesHorizontal, #R], [#choco, #C], [#rests, #S]]
  200.       end if
  201.     end if
  202.   end if
  203.   meSprite.activate(0)
  204. end
  205.  
  206. --------------------------------------------------------------------------------------------------------------------------------
  207. -- Set the f monkey to work!
  208. --------------------------------------------------------------------------------------------------------------------------------
  209.  
  210. on traceMonkey me --n├ñr man ska byta dir-fil, komma ih├Ñg var ap-j ├ñr n├Ñnstans
  211.   if activity <> #S then
  212.     transMember = meSprite.member --s├Ñ att n├ñsta film ska veta vilken member och loc den ska b├╢rja apan med
  213.     transLoc = meSprite.loc
  214.     transFrame = meSprite.frame
  215.   end if
  216. end
  217.  
  218. on interruptMonkeyUpDown me --n├ñr man trycker p├Ñ en ny knapp medan ap-j redan ├ñr ute och r├ñnner och han m├Ñste v├ñnda
  219.   turnMonkey = 1
  220.   interruptFrame = meSprite.frame
  221.   totalFrames = meSprite.member.frameCount
  222.   if interruptFrame < 10 then
  223.     return 1 --s├Ñ liten bit in att det ├ñr b├ñttre att skippa swfen och ta n├ñsta direkt
  224.   else
  225.     totalPercent = totalFrames * 0.01
  226.     perFrame = interruptFrame / totalPercent
  227.     percentFrame = perFrame * 0.01
  228.   end if
  229. end
  230.  
  231. on interruptMonkeyHorisontal me, whichButton, multiply
  232.   if multiply = void then multiply = 1
  233.   interruptFrame = meSprite.frame
  234.   totalFrames = meSprite.member.frameCount
  235.   framesLeft = totalFrames - interruptFrame
  236.   if framesLeft < 10 then
  237.     return 2 --s├Ñ liten bit kvar att det ├ñr b├ñttre att springa klart och sen v├ñnda
  238.   else if interruptFrame < 4 then
  239.     return 1 --s├Ñ liten bit in att det ├ñr b├ñttre att inte g├╢ra n├Ñnting
  240.   else
  241.     if positionH = #R then
  242.       if positionV = #U then
  243.         newStopNum = (ULstopList[whichButton]) * multiply
  244.         newbuttonHvalue = upButtonHListL[whichButton]
  245.       else
  246.         newStopNum = (DLstopList[whichButton]) * multiply
  247.         newbuttonHvalue = downButtonHList[whichButton]
  248.       end if
  249.     else
  250.       if positionV = #U then
  251.         newStopNum = (URstopList[whichButton]) * multiply
  252.         newbuttonHvalue = upButtonHListR[whichButton]
  253.       else
  254.         newStopNum = (DRstopList[whichButton]) * multiply
  255.         newbuttonHvalue = downButtonHList[whichButton]
  256.       end if
  257.     end if
  258.     
  259.     if interruptFrame <= newStopNum then
  260.       StopNum = newStopNum
  261.       buttonHvalue = newbuttonHvalue
  262.       return 1 --knappen ligger ├ñnd├Ñ framf├╢r s├Ñ g├╢r ingenting ├ñr du bussig!
  263.     else
  264.       turnMonkey = 1
  265.       transFrame = framesLeft
  266.     end if
  267.   end if
  268. end
  269.  
  270. on reCoverMe me --fr├Ñn init p├Ñ ap-spriten, s├Ñ att nya filmen ska veta vilken member och loc den ska b├╢rja apan med
  271.   monkeyRunning = 0
  272.   if transMember = 0 then
  273.     restMe me
  274.   else
  275.     meSprite.member = transMember
  276.     meSprite.loc = transLoc
  277.     updateStage
  278.     transMember = 0
  279.     transLoc = 0
  280.     
  281.     if activity <> #b then --om apan blir avbruten av annat klick n├ñr den redan ├ñr ig├Ñng
  282.       meSprite.setFrameStart(transFrame)
  283.       transFrame = 0
  284.     else --om apan st├Ñr och trycker p├Ñ en knapp
  285.       transFrame = stopNum
  286.       stopNum = 0
  287.       switchPositionValue me, #H
  288.       playList = initPlay
  289.     end if
  290.     
  291.     meSprite.activate(0)
  292.   end if
  293. end
  294.  
  295.  
  296. on reloadMe me
  297.   makeOne me,  playList[1][1], playList[1][2]
  298.   playList.deleteAt(1)
  299. end
  300.  
  301.  
  302. --------------------------------------------------------------------------------------------------------------------------------
  303. on makeOne me, PactivityList, Pactivity
  304.   setValues me, PactivityList, Pactivity
  305.   makeName me
  306.   setmember me
  307. end
  308.  
  309. on setValues me, PactivityList, Pactivity --best├ñmma v├ñrdena
  310.   activityList = PactivityList
  311.   formerActivity = activity
  312.   activity = Pactivity
  313. end
  314.  
  315. on setmember me --s├ñtta member liksom
  316.   if MEMBERSX[activityList][Pname] <> "" then
  317.     
  318.     meSprite.member = member(MEMBERSX[activityList][Pname]&myColor, 2)
  319.     meSprite.loc = Ploc
  320.     updatestage
  321.     
  322.     ---nytt
  323.     if percentFrame <> 0 then --om apan ska v├ñnda ├Ñt andra h├Ñllet
  324.       if transFrame = 0 then
  325.         totFrame = meSprite.member.frameCount
  326.         perFrame = totFrame * percentFrame
  327.         transFrame = integer(totFrame - perFrame)
  328.         percentFrame = 0
  329.       end if
  330.     end if
  331.     turnMonkey = 0
  332.     
  333.     ---nytt slut
  334.     
  335.     if transFrame <> 0 then
  336.       meSprite.setFrameStart(transFrame)
  337.       transFrame = 0
  338.     end if
  339.     
  340.     if Pname = #DL or Pname = #DR then 
  341.       positionV = #D
  342.     else if Pname = #UL or Pname = #UR then
  343.       positionV = #U
  344.       --    else if Pname = #RL or Pname = #AL then
  345.       --      positionH = #R
  346.       --    else if Pname = #RR or Pname = #AR then
  347.       --      positionH = #L
  348.     end if
  349.   end if
  350. end
  351.  
  352. on makeName me --tillverka ett l├ñmpligt namn och hoppas att det finns en castmember som passar
  353.   case activityList of
  354.     #movesVertical: 
  355.       Pname = symbol(activity&positionH)
  356.       Ploc = POSITIONS[activityList][positionH]
  357.       --      switchPositionValue me, #V
  358.     #movesHorizontal: 
  359.       Pname = symbol(activity&positionH)
  360.       nom = symbol(activity&positionV)
  361.       Ploc = POSITIONS[activityList][nom]
  362.       switchPositionValue me, #H
  363.     #corners: 
  364.       Pname = symbol(formerActivity&activity&positionH)
  365.       nom = symbol(positionV&positionH)
  366.       Ploc = POSITIONS[activityList][nom]
  367.     #rests: 
  368.       Pname = symbol(activity&(random(2))&positionH)
  369.       Ploc = POSITIONS[activityList][positionH]
  370.     #choco:
  371.       Pname = symbol(activity&"L")
  372.       Ploc = POSITIONS[activityList][positionH]
  373.     #restHard:
  374.       Pname = symbol(activity&1&positionH)
  375.       Ploc = POSITIONS[activityList][positionH]
  376.     #buttons:
  377.       if buttonV = #U then
  378.         Pname = symbol(activity&(random(2))&positionH)
  379.         Ploc = point(buttonHvalue, 75)
  380.       else
  381.         Pname = symbol(activity&(random(2))&positionHButtons)
  382.         Ploc = point(buttonHvalue, 608)
  383.       end if
  384.   end case
  385. end
  386. --------------------------------------------------------------------------------------------------------------------------------
  387. on switchPositionValue me, p --├ñndra fr├Ñn upp till ner och h├╢ger till v├ñnster ├Ñ s├Ñnt d├ñrnt
  388.   if p = #H then
  389.     if positionH = #L then
  390.       positionH = #R
  391.     else
  392.       positionH = #L
  393.     end if
  394.     --  else
  395.     --    if positionV = #U then
  396.     --      positionV = #D
  397.     --    else
  398.     --      positionV = #U
  399.     --    end if
  400.   end if
  401. end
  402.  
  403.  
  404. --------------------------------------------------------------------------------------------------------------------------------
  405. -- return calls
  406.  
  407. on activateGoScript me --skicka tillbaks till knappen att det ├ñr klart f├╢r avf├ñrd till n├ñsta dir-movie
  408.   traceMonkey me
  409.   buttonSprite.GoScript()
  410. end
  411.  
  412. --------------------------------------------------------------------------------------------------------------------------------
  413. --initValues
  414. --------------------------------------------------------------------------------------------------------------------------------
  415.  
  416. on readValues me --h├ñnder bara n├ñr man startar cdn 
  417.   
  418.   MEMBERSX = \
  419. [ \
  420. #movesVertical: \
  421. [#UL: "hna1001", #DL: "hna1003", #UR: "hna1002", #DR: "hna1004"], \
  422. #movesHorizontal: \
  423. [#AL: "hna1027", #RL: "hna1029", #AR: "hna1028", #RR: "hna1030"], \
  424. #corners: \
  425. [#SRL: "", #RSL: "", #SAL: "hna1010", #ASL: "hna1009", #SDL: "hna1011", #USL: "hna1013", #ADL: "hna1012", #UAL: "hna1013", #RDL: "hna1012", #URL: "hna1013", #DRL: "hna1031", #RUL: "hna1031", #SRR: "", #RSR: "", #SAR: "hna1021", #ASR: "hna1020", #SDR: "hna1022", #USR: "hna1024", #ADR: "hna1023", #UAR: "hna1024", #RDR: "hna1023", #URR: "hna1024", #DRR: "hna1032", #RUR: "hna1032"], \
  426. #rests: \
  427. [#S1L: "hna1005", #S2L: "hna1006", #S3L: "hna1015", #S4L: "hna1014", #S1R: "hna1016", #S2R: "hna1017", #S3R: "hna1026", #S4R: "hna1025"], \
  428. #choco: \
  429. [#CL: "isia02"], \
  430. #restHard: \
  431. [#S1L: "hna1005", #S1R: "hna1016"], \
  432. #buttons: \
  433. [#B1R: "hna1007", #B2R: "hna1008", #B1L: "hna1018", #B2L: "hna1019"] \
  434. ]
  435.   
  436.   POSITIONS = \
  437. [ \
  438. #movesVertical: \
  439. [#L: point(53, 294), #R: point(740, 295)], \
  440. #movesHorizontal: \
  441. [#RU: point(400, 53), #RD: point(400, 578), #AU: point(400, 102)], \
  442. #corners: \
  443. [#UL: point(85, 85), #UR: point(703, 85), #DL: point(75, 540), #DR: point(733, 540)], \
  444. #rests: \
  445. [#L: point(30, 80), #R: point(750, 80)], \
  446. #choco: \
  447. [#L: point(73, 81)], \
  448. #restHard: \
  449. [#L: point(40, 80), #R: point(745, 80)] \
  450. ]
  451.   
  452. end
  453.  
  454. --------------------------------------------------------------------------------------------------------------------------------
  455. on new me --(f├╢ds en enda g├Ñng fr├Ñn sessionobject on new)
  456.   
  457.   percentFrame = 0 ---Nytt!!!!
  458.   transFrame = 0 ---Nytt!!!!
  459.   
  460.   meSprite = sprite(150)
  461.   myColor = string(sessionobject.myColor).char[1]
  462.   readValues me
  463.   positionH = #L
  464.   positionV = #U
  465.   activity = #S
  466.   playList = []
  467.   ULstopList = [4, 8, 11, 14, 19, 22, 25, 29, 33, 36] --frameNums in runningFlash
  468.   URstopList = [36, 33, 29, 25, 23, 19, 15, 12, 8, 4]
  469.   upButtonHListL = [110, 165, 219, 269, 339, 382, 437, 495, 560, 620] --locValues for buttonFlash
  470.   upButtonHListR = [176, 229, 286, 352, 402, 452, 516, 566, 626, 673]
  471.   DLstopList = [2, 5, 30, 34, 40] --frameNums in runningFlash
  472.   DRstopList = [40, 36, 12, 9, 4]
  473.   downButtonHList = [115, 170, 520, 574, 667] --locHValues for buttonFlash
  474.   return me
  475. end
  476.  
  477. --------------------------------------------------------------------------------------------------------------------------------
  478.  
  479.